package com.ycz.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author:ycz
 * @date:2021/6/8
 */
@Component
public class UserService {

    @Autowired
    private JdbcTemplate jdbcTemplate;


    @Transactional
    public void testTransaction() {
        jdbcTemplate.execute("insert into t_user values (1,1,1)");
        throw new NullPointerException();
    }


    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }
}
